<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!--<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">-->
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
		<script type="text/javascript" src="./libs/spark-md5-3.0.0.min.js"></script>
	    <script type="text/javascript" src="./libs/crypto-js.js"></script>
	    <script type="text/javascript" src="./libs/base64.min.js"></script>
	    <script type="text/javascript" src="./libs/ufile-token.js"></script>
		<style>
			.fr_title {
				display: table-cell;
				width: 100%;
				vertical-align: middle;
				height: 34px;
			}
			
			.fr_swich .fr_swich_txt {
				width: 50px;
			}
			
			.inline-block {
				display: inline-block;
			}
			
			input.picInput {
				display: none;
			}
			
			img.picShow {
				width: 80px;
			}
			
			.leftState{
				padding:0;
				min-width:120px;
				max-width:150px;
			}
		</style>
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content-header ">
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i>系统设置</a>
						</li>
						<li class="active">系统设置</li>
					</ol>
				</section>
				<section class="content">
					<div class="box box-primary">
						<div class="box-body">
							<div class="row">
								<div class="col-xs-12">
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 平台金币单位 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="input-group-btn">
														<button type="button" class="btn btn-default" aria-expanded="false">币种</button>
													</div>
													<select type="text" class="form-control" id="platform_unit">
														<option value="USD">USD</option>
													</select>
												</div>
											</div>
										</div>
									</div>
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 邀请奖励 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<select class="form-control" id="invite_reward_status">
														<option value="1">开启</option>
														<option value="0">关闭</option>
													</select>
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 一级推广币数量 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<input type="text" class="form-control" id="invite_first_num" />
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 二级推广币数量 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<input type="text" class="form-control" id="invite_second_num" />
													
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 超级推广币数量 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<input type="text" class="form-control" id="super_reward_num" />
													
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 注册送币 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="input-group-btn">
														<button type="button" class="btn btn-default" aria-expanded="false">
															<select id="register_reward_status">
																<option value="1">开启</option>
																<option value="0">关闭</option>
															</select>
														</button>
													</div>
													<input type="text" class="form-control" id="register_reward_num" style="height:36px;" />
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 奖励币 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<select type="text" class="form-control coin_id" id="reward_coin_id"></select>
													
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 奖励币总数 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<input type="text" class="form-control coin_id" id="reward_coin_num">
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 游戏提现币 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<select type="text" class="form-control coin_id" id="game_coin_id"></select>
												</div>
											</div>
										</div>
									</div> -->
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 下载地址 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<span class="input-group-addon"><i class="fa fa-fw fa-globe"></i></span>
													<input type="text" class="form-control" id="download_url" />
												</div>
											</div>
										</div>
									</div>
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 邀请规则 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<textarea type="text" class="form-control" rows="5" id="invite_rule" /></textarea>
													
												</div>
											</div>
										</div>
									</div> -->

									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 管理员号码</br> （多个可，隔开）</div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<textarea type="text" class="form-control" rows="2" id="msg_phone" /></textarea>
												</div>
											</div>
										</div>
									</div>
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 实名失败上限 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<input type="text" class="form-control" id="auth_device_black_num" />
													<span class="input-group-addon">次</span>
												</div>
											</div>
										</div>
									</div> -->
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 单设备实名上限 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<input type="text" class="form-control" id="auth_device_success_num" />
													<span class="input-group-addon">次</span>
												</div>
											</div>
										</div>
									</div> -->
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 单设备注册上限 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<input type="text" class="form-control" id="device_register_max" />
													<span class="input-group-addon">次</span>
												</div>
											</div>
										</div>
									</div>
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title">是否允许用户实名</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="user_auth_status">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div> -->
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title">设备校验是否开启</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="device_verify_status">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title">是否使用CF高防</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="safe_use_cf">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									
									<!-- <div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title">私募交易开关</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="simu_transaction_status">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div> -->
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title">关闭对外转账</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="transaction_out_status">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 是否需要邀请码</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="need_invite_code">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 是否显示弹出窗</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" id="show_popup">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> APP处于更新中</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<div class="fr_swich" trueText="更新中" falseText="正常" id="is_update">
														<div class="fr_swich_body"></div>
														<span class="fr_swich_txt">否</span>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 弹出窗跳转地址</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<span class="input-group-addon"><i class="fa fa-fw fa-globe"></i></span>
													<input type="num" class="form-control" id="popup_to_url">
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 弹出窗背景图片</div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<label style="display: inline-block;">
														<input type="file" class="form-control onePic picInput" id="popup_pic_url" name="popup_pic_url"/>
														<img src="img/add.png" class="picShow" alt="" />
													</label>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 客服微信二维码 </div>
											</div>
											<div class="col-xs-8">
												<div class="">
													<label style="display: inline-block;">
														<input type="file" class="form-control onePic picInput" id="wx_qr_code" name="wx_qr_code"/>
														<img src="img/add.png" class="picShow" alt="" />
													</label>
												</div>
											</div>
										</div>
									</div>
									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 关于我们</div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<span class="input-group-addon"><i class="fa fa-fw fa-globe"></i></span>
													<input type="num" class="form-control" id="about_url">
												</div>
											</div>
										</div>
									</div>

									<div class="col-xs-12 margin">
										<div class="col-xs-12 col-sm-10 col-md-8">
											<div class="col-xs-3 leftState">
												<div class="fr_title"> 操作密码 </div>
											</div>
											<div class="col-xs-8">
												<div class="input-group">
													<span class="input-group-addon"><i class="fa fa-lock"></i></span>
													<input type="text" class="form-control" id="op_password" autocomplete="off">
													<input type="hidden" id="op_password_init" />
												</div>
											</div>
										</div>
									</div>
									
								</div>
								<div class="col-xs-12 margin">
									<button class="btn btn-flat margin btn-success" onclick="opPwModal()" style="margin-left:30px;">保存</button>
								</div>
							</div>
						</div>
					</div>
				</section>
			</div>
		</div>
		<div class="modal fade parents in" id="opPwModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">	                  				
							<span aria-hidden="true">×</span>								
						</button>
						<h4 class="modal-title">操作密码</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal">
					 		<div class="box-body"> <input type="hidden" name="id" value="">
								<label class="margin-bottom-none col-xs-12" style="padding-left: 0;">
										<input type="password" class="form-control"  name="opPw">
									</label>
							</div>
						</form>
					</div>
					<div class="modal-footer"> <button type="button" class="btn btn-primary save" onclick="set()">确定</button> </div>
				</div>
			</div>
		</div>
	</body>
	<script src="bower_components/jquery/dist/jquery.min.js"></script>
	<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
	<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

	<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

	<script src="dist/js/adminlte.min.js"></script>
	<script src="js/argument.js"></script>
	<script src="js/fun.js"></script>
	<script src="js/nav.js"></script>
	<script src="js/pop.js"></script>
	<script src="js/getList.js"></script>

	<script type="text/javascript">
		//need_invite_code
		$(function() {
			console.log($("[code = 300]"))
		})
		//获取
		function renderSet() {
			$.ajax({
				type: "post",
				'contentType': "application/x-www-form-urlencoded",
				"headers": {
					"auth-token": localStorage.getItem("wallet_token")
				},
				url: url + "Back_GetSetting",
				dataType: 'json',
				success: function(res) {
					if(res.status == 1) {
						$.each(res.data, function(index, item) {
							if(index == 'need_invite_code'||index == 'show_popup'||index == 'transaction_out_status'||index == 'device_verify_status'||index == 'safe_use_cf'||index == 'is_update') {
								if(item == 1) {
									var text = $('#'+index).attr('trueText')||'是'
									$('#'+index).addClass('active').find(".fr_swich_txt").text(text);
								} else {
									console.log(index)
									console.log($('#'+index).attr('falseText'))
									var text = $('#'+index).attr('falseText')||'否'
									$('#'+index).removeClass('active').find(".fr_swich_txt").text(text);
								}
								return true;
							}else if(index == 'popup_pic_url' || index == 'wx_qr_code'){
								$('#'+index).attr('img_url',item).siblings('img').attr('src',bucketUrl + item);
								return true;
							}
							$("#" + index).val(item);
						})
						if($("#register_reward_status").val() == 0) {
							$("#register_reward_num").prop("disabled", true);
						}
						$('#op_password_init').val(res.data.op_password)
					} else {
						alert(res.msg);
					}
				}
			})
		}
		$(".fr_swich").click(function() {
			if($(this).hasClass('active')) {
				var text = $(this).attr('falseText')||'否'
				$(this).removeClass('active').find(".fr_swich_txt").text(text);
			} else {
				var text = $(this).attr('trueText')||'是'
				$(this).addClass('active').find(".fr_swich_txt").text(text);
			}
		})

		$("#register_reward_status").change(function() {
			if($("#register_reward_status").val() == 0) {
				$("#register_reward_num").prop("disabled", true);
			} else {
				$("#register_reward_num").prop("disabled", false);
			}
		})

		function opPwModal() {
			$("#opPwModal input").val("");
			$("#opPwModal").modal('show');
		}

		function set() {
			
			//is_update
 
			//输入框
			var list = [ "download_url", "about_url",  'msg_phone', 'popup_to_url','device_register_max',];
			//开关
			var switchList =['need_invite_code','show_popup','transaction_out_status','device_verify_status','safe_use_cf','is_update'];
			//图片
			var imgList = ['popup_pic_url','wx_qr_code'];
			
			var data = {
				op_password: $("#opPwModal [name = opPw]").val(),
			}
			$.each(list, function(index, item) {
				data[item] = $("#" + item).val()
			})
			$.each(switchList, function(index, item) {
				data[item] = ($("#"+item).hasClass('active')) ? 1 : 0
			})
			$.each(imgList, function(index, item) {
				data[item] = $("#"+item).attr('img_url')
			})
			if($("#op_password").val() != "") {
				data.update_password = $("#op_password").val()
			}
			console.log(data)
			$.ajax({
				type: "post",
				'contentType': "application/x-www-form-urlencoded",
				"headers": {
					"auth-token": localStorage.getItem("wallet_token")
				},
				url: url + "Back_UpdateSetting",
				data: {
					data: JSON.stringify(data)
				},
				dataType: 'json',
				success: function(res) {
					if(res.status == 1) {
						move("success", res.error)
						$("#opPwModal").modal('hide');
					} else if(res.status == 1000||res.status == 102) {
						ToLogin(res);
					} else {
						alert(res.error);
						renderSet();
						$("#opPwModal").modal("hide");
						return false;
					}
				}
			})
		}

		$.ajax({
			type: "post",
			'contentType': "application/x-www-form-urlencoded",
			"headers": {
				"auth-token": localStorage.getItem("wallet_token")
			},
			url: url + "Back_MainChainForCoin",
			data: {
				data: JSON.stringify({
					page_num: 1
				})
			},
			dataType: 'json',
			success: function(res) {
				if(res.status == 1) {
					$.each(res.data, function(index, item) {
						$(".coin_id").append("<option value='" + item.id + "'>" + item.name + "</option>")
					})
					renderSet();
				} else if(res.status == 1000||res.status == 102) {
					ToLogin(res);
				} else {
					alert(res.error);
					return false;
				}
			}
		})

		$(".onePic").change(function() {
			var ufile =  new UCloudUFile(bucketName, bucketUrl, tokenPublicKey, tokenPrivateKey, tokenServerUrl, prefix);
			var date = new Date()
			var fileRename = date.valueOf()+Math.ceil(Math.random()*100);
			var file = $(this)[0].files[0];
			console.log(file);
			var that = $(this)
			var data = {
				file: file,
				fileRename: fileRename
			};
			var errorCallBack = function(res) {
				console.log(res)
			};
			var successCallBack = function(res) {
				that.siblings('img').attr("src", bucketUrl + fileRename)
				that.attr('img_url',fileRename);
			};
			var progressCallBack = function(res) {};

			ufile.uploadFile(data, successCallBack, errorCallBack, progressCallBack);
		})
	</script>
	</body>

</html>